import request from '../utils/request'
//同意商品上架
export const AgreeProductService = (itemId: number) => {
  return request.put(`/admin/agreeItem/${itemId}`)
}
//拒绝商品上架
export const RefuseProductService = (itemId: number, reason: string) => {
  return request.put(`/admin/refuseItem/${itemId}?reason=${encodeURIComponent(reason)}`)  
}
//禁用用户
export const disableUserService = (userId: number) => {
  return request.put(`/admin/disableUser?userId=${encodeURIComponent(userId)}`)
}
//禁用商户
export const disableMerchantService = (merchantId: number) => {
  return request.put(`/admin/disableMerchant?merchantId=${encodeURIComponent(merchantId)}`)
}
//解禁用户
export const enableUserService = (userId: number) => {
  return request.put(`/admin/enableUser?userId=${encodeURIComponent(userId)}`)
}
//解禁商户
export const enableMerchantService = (merchantId: number) => {
  return request.put(`/admin/enableMerchant?merchantId=${encodeURIComponent(merchantId)}`)
}

//根据用户名分页查询用户
export const getUserByName=(pageNum: number, pageSize: number,keyword: string)=>{
  if(keyword===''){
    keyword='%'
  }
  return request.get('/admin/findUserByName', { params: { pageNum, pageSize,keyword } })
}
//根据商户名分页查询商户
export const getMerchantByName=(pageNum: number, pageSize: number,keyword: string)=>{
  if(keyword===''){
    keyword='%'
  }
  return request.get('/admin/findMerchantByName', { params: { pageNum, pageSize,keyword } })
}

//根据用户名和订单号分页查询用户余额支付订单
export const getBalanceOrder=(pageNum: number, pageSize: number,userKeyword: string,orderNoKeyword:string,orderStatus:number)=>{
  //如果用户名为空，就查询所有用户名
  if(userKeyword===''){
    userKeyword='%'
  }
  //如果订单号为空，就查询所有订单号
  if(orderNoKeyword===''){
    orderNoKeyword='%'
  }
  return request.get('/admin/findUserBalancePayOrdersByKeyword', { params: { pageNum, pageSize,userKeyword,orderNoKeyword ,orderStatus} })
}

//根据状态和商品信息模糊搜索,itemCategory: string,itemKeyword: string,itemBrand:string是可选，其余三个是必选
export const getItemsByStateAndName=(pageNum: number, pageSize: number,state: number,
  itemCategory: string,itemKeyword: string,itemBrand:string)=>{
  return request.get('/admin/findItemsByStateAndName', { params: { pageNum, pageSize,state,itemCategory,itemKeyword ,itemBrand} })
}

// 退款请求参数传递
export const OrderRefund = (orderNo: string) => {
  const BigOrderNo=BigInt(orderNo)
  return request.put(`/alipay/orderRefund`, null, {
    params: { BigOrderNo }
  })
}

